Hector (API)
   HOME

TheInfoList



OR:

Hector is a high-level client
API An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
for
Apache Cassandra Cassandra is a free and open-source, distributed, wide-column store, NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassand ...
. Named after
Hector In Greek mythology, Hector (; grc, Ἕκτωρ, Hektōr, label=none, ) is a character in Homer's Iliad. He was a Trojan prince and the greatest warrior for Troy during the Trojan War. Hector led the Trojans and their allies in the defense o ...
, a warrior of
Troy Troy ( el, Τροία and Latin: Troia, Hittite: 𒋫𒊒𒄿𒊭 ''Truwiša'') or Ilion ( el, Ίλιον and Latin: Ilium, Hittite: 𒃾𒇻𒊭 ''Wiluša'') was an ancient city located at Hisarlik in present-day Turkey, south-west of Ç ...
in
Greek mythology A major branch of classical mythology, Greek mythology is the body of myths originally told by the ancient Greeks, and a genre of Ancient Greek folklore. These stories concern the origin and nature of the world, the lives and activities ...
, it is a substitute for the Cassandra Java Client, or Thrift, that is encapsulated by Hector. It also has
Maven MAVEN is an American spacecraft orbiting Mars to study the loss of its atmospheric gases to space, providing insight into the history of the planet's climate and water. The spacecraft name is an acronym for "Mars Atmosphere and Volatile Evolu ...
repository access.


History

As Cassandra is shipped with the low-level
Thrift (protocol) Thrift is an interface definition language and binary communication protocol used for defining and creating services for numerous programming languages. It was developed at Facebook for "scalable cross-language services development" and as of ...
, there was a potential to develop a better protocol for application developers. Hector was developed by Ran Tavory as a high-level interface that overlays the shortcomings of Thrift. It is licensed with the MIT License that allows to use, modify, split and change the design.


Features

The high-level features of Hector are * A high-level object oriented interface to Cassandra: It is mainly inspired by the Cassandra-java-client. The API is defined in the Keyspace interface. * Connection pooling. As in high-scale applications, the usual pattern for
DAO Dao, Dão or DAO may refer to: * Tao (Chinese: "The Way" 道), a philosophical concept * Dao (Chinese sword) (刀), a type of Chinese sword * Dao (Naga sword), a weapon and a tool of Naga people People and language * Yao people, a minority ethni ...
s is a large number of reads/writes. It is too expensive for clients to open new connections with each request. So, a client may easily run out of available sockets, if it operates fast enough. Hector provides connection pooling and a nice framework that manages the details. * Failover support: As Cassandra is a distributed data store where hosts ( ''nodes'') may go down. Hector has its own failover policy. * JMX support: Hector exposes JMX for many important runtime metrics, such as number of available connections, idle connections, error statistics. * Load balancing: A simple load balancing exists in the newer version. * Supports the command design pattern to allow clients to concentrate on their business logic and let Hector take care of the required plumbing.


Availability metrics

Hector exposes availability counters and statistics through JMX.


Load balancing

Hector follows two load balancing policies with the LoadBalancingPolicy interface. The default is called RoundRobinBalancingPolicy and is a simple round-robin distribution algorithm. The LeastActiveBalancingPolicy routes requests to the pools having the lowest number of active connections, ensuring a good spread of utilisation across the cluster. .


Pooling

The ExhaustedPolicy determines how the underlying client connection pools are controlled. Currently, three options are available:


Code examples

As an example, an implementation of a simple distributed
hashtable In computing, a hash table, also known as hash map, is a data structure that implements an associative array or dictionary. It is an abstract data type that maps keys to values. A hash table uses a hash function to compute an ''index'', also ...
over Cassandra is listed. /** * Insert a new value keyed by key * @param key Key for the value * @param value the String value to insert */ public void insert(final String key, final String value) throws Exception /** * Get a string value. * @return The string value; null if no value exists for the given key. */ public String get(final String key) throws Exception /** * Delete a key from cassandra */ public void delete(final String key) throws Exception


References


External links


Apache Thrift

Hector on github

The Cassandra Java client
{{DEFAULTSORT:Hector (Api) Distributed computing Distributed data stores Java (programming language)